﻿using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class _NewsArticle : System.Web.UI.Page 
{
    protected LocalFunctions FUNC;
    private int articeID;
    
    protected string sArticle;
    protected string sTitle;

    protected string sKeywords, sDescription;

    protected void Page_Load(object sender, EventArgs e)
    {
        FUNC = ((Rondo)Master).FUNC;

        GetParameters();

        GetArticleData();
        if(FUNC.LangID==2)
            tblContent.Attributes.Add("dir", "rtl");
    }

    private void GetParameters()
    {
        articeID = Convert.ToInt32(Request.QueryString["id"]);
    }

    private void GetArticleData()
    {
        Dal.arParams.Clear();
        Dal.arParams.Add(articeID);
        DataTable DT = Dal.ExecuteDBsp("RD_GetNewsArticle", Dal.arParams);
        if(DT!=null)
            if (DT.Rows.Count > 0)
            {
                Title = DT.Rows[0]["Title"].ToString();
                sDescription=DT.Rows[0]["SubTitle"].ToString();
                ContentTitle.InnerHtml = "<h1>" + DT.Rows[0]["Title"].ToString() + "</h1>";
                PageContent.InnerHtml = "<p>" + DT.Rows[0]["Content"].ToString() + "</p>";

                string sImage = DT.Rows[0]["imagePath"].ToString();
                if (sImage.Length > 0)
                {
                    imgTitle.Src = FUNC.FullAppPath + "/Gallery/" +sImage;
                }
                else
                {
                    Dal.arParams.Clear();
                    Dal.arParams.Add(11); // vidio galery
                    Dal.arParams.Add(FUNC.LangID);
                    DataTable DTtitle = Dal.ExecuteDBsp("RD_SelectStaticPageById", Dal.arParams);
                    if (DTtitle != null)
                    {
                        if (DTtitle.Rows.Count > 0)
                        {
                            imgTitle.Src = FUNC.FullAppPath + "/Gallery/" + DTtitle.Rows[0]["imageLink"].ToString();
                        }
                    }
                }
            }
    }
}
